<?php
/**
 * Created by PhpStorm.
 * User: FoxxxZhu
 * Date: 2017/12/26
 * Time: 14:42
 */

namespace Forxx;

use Lavender\Dao\RedisTable;
class MessageQueue extends RedisTable{
    protected $table = "message_queue";
    protected $prefix = "mq";
    protected $_id = "video";
    public function push($data)
    {
        $key = $this->makeKey($this->_id);
        $jsonData = $this->pack($data);
        return $this->rpush($key,$jsonData);
    }

    public function pop()
    {
        $key = $this->makeKey($this->_id);
        $data = $this->lpop($key);
        if(!empty($data))
        {
            return $this->unpack($data);
        }
    }

    public function length()
    {
        $key = $this->makeKey($this->_id);
        return $this->llen($key);
    }

}